package com.itany.corejava.day09;

import java.util.Arrays;
import java.util.Comparator;

public class Test2 {

    public static void main(String[] args) {


        Student s1=new Student(5,"aaa",43);
        Student s2=new Student(1,"bbb",98);
        Student s3=new Student(3,"ccc",25);
        Student s4=new Student(6,"ddd",75);
        Student s5=new Student(2,"eee",68);
        Student s6=new Student(4,"fff",88);


        Student[] ss={s1,s2,s3,s4,s5,s6};

        Arrays.sort(ss);

        for (int i = 0; i < ss.length; i++) {
            Student student=ss[i];
            System.out.println(student.getId()+"\t"+student.getName()+"\t"+student.getScore());
        }

        System.out.println("-------------------------------------------");

        Arrays.sort(ss, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getScore()-o2.getScore();
            }
        });


        for (int i = 0; i < ss.length; i++) {
            Student student=ss[i];
            System.out.println(student.getId()+"\t"+student.getName()+"\t"+student.getScore());
        }

        System.out.println("-------------------------------------------");

        Arrays.sort(ss, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getScore()-o1.getScore();
            }
        });


        for (int i = 0; i < ss.length; i++) {
            Student student=ss[i];
            System.out.println(student.getId()+"\t"+student.getName()+"\t"+student.getScore());
        }


        System.out.println("-------------------------------------------");

        Arrays.sort(ss,(o1,o2)->o2.getScore()-o1.getScore());



        for (int i = 0; i < ss.length; i++) {
            Student student=ss[i];
            System.out.println(student.getId()+"\t"+student.getName()+"\t"+student.getScore());
        }

















    }


}
